package com.sk.bilibili.view.fragment.main.home.home;

import android.view.View;

import com.alibaba.android.vlayout.DelegateAdapter;
import com.sk.bilibili.adapter.vlayout.HeaderAdapter;
import com.sk.bilibili.adapter.vlayout.main.home.hot.RankAdapter;
import com.sk.bilibili.bean.VideoSet;
import com.sk.bilibili.model.fragment.main.home.home.HotModel;
import com.sk.bilibili.view.activity.MemberActivity;
import com.sk.bilibili.view.activity.RankActivity;
import com.sk.bilibili.view.activity.VideoSetActivity;
import com.sk.bilibili.view.diy.bottomDialog.LaterBottomDialog;
import com.sk.bilibili.view.fragment.BaseRefreshFragment;

import java.util.List;

public class HotFragment extends BaseRefreshFragment<HotModel> implements View.OnClickListener {

    private RankAdapter rankAdapter;
    private LaterBottomDialog laterBottomDialog;

    public HotFragment() {
        laterBottomDialog=new LaterBottomDialog();
    }

    @Override
    protected void initAdapter(DelegateAdapter adapter) {
        adapter.addAdapter(new HeaderAdapter(getContext(), this));
        rankAdapter = new RankAdapter(getContext(), this);
        adapter.addAdapter(rankAdapter);
    }

    public void refreshSuccess(List<VideoSet> videoSets) {
        rankAdapter.setData(videoSets);
        cancelRefresh();
    }

    public void onVideoSetClick(Integer id) {
        VideoSetActivity.start(getContext(),id);
    }

    public void onMemberClick(Integer id) {
        MemberActivity.start(getContext(),id);
    }

    @Override
    public void onClick(View v) {
        RankActivity.start(getContext(),0);
    }

    public void onMoreClick(Integer id) {
        laterBottomDialog.show(getChildFragmentManager(),id);
    }

}